Introduce a simple cache and build a new ReferenceContext only when needed#158
Open
marcelthole wants to merge 2 commits intocebe:masterfrom
Open
Introduce a simple cache and build a new ReferenceContext only when needed#158marcelthole wants to merge 2 commits intocebe:masterfrom
marcelthole wants to merge 2 commits intocebe:masterfrom
Conversation
…ntext only when needed
26a5d92 to
9edcbd2
Compare
cebe
reviewed
Apr 20, 2022
src/spec/Reference.php
Outdated
| class Reference implements SpecObjectInterface, DocumentContextInterface | ||
| { | ||
| /** @var array<string, mixed> */ | ||
| private static $relativeReferencesCache = []; |
Owner
There was a problem hiding this comment.
this could probably cause issues when the library is used to read multiple different OpenAPI descriptions in the same process. Ideally the cache should be bound to the context like we have it with ReferenceContextCache.
Contributor
Author
There was a problem hiding this comment.
yeah you are right. I used the ReferenceContextCache.
But this reduced the perfomance of the first variant. The first version only used 1.3 Million times this method, the current version 4.3 Million times. But it's still better than the original version with 9.8 Million function calls
…rs with multiple files in a single process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hey, maybe this could work and improve the perfomance for the use case in #156.
Here is a simple repo script:
and this are the before and after results

(left after the change, right before)